﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using Yule8xCommon.Applib;

namespace Yule8xWechat.PublicServices
{
    public partial class NoticeService : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int count = RequestUtil.GetInteger("count");
            // 随机从数据库或文本文件读取随机名字
            string nicknamecontent = RuntimeDataUtil.GetNickNameText();
            if (nicknamecontent.Length > 1)
            {
                IList<string> nicknamesList = nicknamecontent.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                ArrayUtil.RandomArray<string>(ref nicknamesList);
                IList<string> outList = new List<string>();
                int i = 0;
                if (count < 1)
                {
                    count = 10;
                }
                foreach(string str in nicknamesList)
                {
                    if (i > count)
                    {
                        break;
                    }
                    outList.Add(string.Format("恭喜{0}成为代理", str));
                    i++;
                }
                if (outList.Count > 0)
                {
                    ResponseUtil.AjaxWrite(JSON.stringify(outList));
                }
            }
        }
    }
}